/*
 * Group 3, User Interface Programming II (vt11)
 * Pooya | Flora | Monica | Can
 */
package vical.action;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;
import vical.model.Internationalization;
import vical.view.MainWindow;

/**
 * The action to exit the program
 * 
 * @author Can
 */
public class ExitAction extends AbstractAction {
    
    private MainWindow mainWindow;

    public ExitAction(MainWindow mainWindow) {
        super(Internationalization.getString("exit"));
        this.mainWindow = mainWindow;
        putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("control X"));
    }

    public void actionPerformed(ActionEvent e) {
        // save the parameters of mainWindow
        // it's hard code, might be improved. (to save for all open windows)
        mainWindow.saveParameters();
        System.exit(0);
    }
}
